package com.yangquan.ayuan.threadTermination;

public class ThreadStopExample extends Thread {
    @Override
    public void run() {
        try {
            for (int i = 0; i < 100000; i++) {
                System.out.println("Running... " + i);
            }
            System.out.println("子线程执行结束");
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}

class App_4 {
    public static void main(String[] args) throws InterruptedException {
        ThreadStopExample example = new ThreadStopExample();
        example.start();
        Thread.sleep(100);
        example.stop(); // stop() 方法停止一个线程
    }
}